﻿package org.leles.utils 
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author Bruno leles
	 */
	public class CallFunction 
	{
		public var object:Object;
		public var event:String;
		public var func:Function;
		public var args:Array;
		
		public function CallFunction(object:EventDispatcher, event:String, func:Function, args:Array) 
		{
			this.object		= object;
			this.func		= func;
			this.event		= event;
			this.args		= args;
			
			object.addEventListener( event, eventCallBack);
		}
		
		private function eventCallBack(e:Event):void 
		{
			func.call(NaN, args);
		}
		
		public static function create(object:EventDispatcher, event:String, func:Function, ... args):CallFunction 
		{
			return new CallFunction(object, event, func, args);
		}
	}
	
}